<?php
class ModelFidoAdvertisement extends Model {
	public function getActiveAdvertisement() {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "logo p LEFT JOIN " . DB_PREFIX . "logo_description pd ON (p.logo_id = pd.logo_id) WHERE logo_active = '1' AND enabled='1' AND pd.language_id = '" . (int)$this->config->get('config_language_id') ."' AND end_date>=NOW()");
		return $query->rows;
	}

	public function getAdvertisementData($logo_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "logo p LEFT JOIN " . DB_PREFIX . "logo_description pd ON (p.logo_id = pd.logo_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.logo_id = '" . (int)$logo_id . "' AND end_date>=NOW()");
		return $query->row;
	}
	public function updateHits($logo_id) {
		$this->db->query("UPDATE " . DB_PREFIX . "logo SET hits = hits + 1 WHERE logo_id = '" . (int)$logo_id . "'");
	}
}
?>
